	function readSingleFile(evt,img) {
		if (evt.files && evt.files[0]) {
			var r = new FileReader();
			r.onload = function(e) {
				$("."+img).attr("src",e.target.result);
			}
			r.readAsDataURL(evt.files[0]);
		}
	}
	$(document).ready(function(){
		$(".img1").click(function(){
			$(".fimg1").click();
		});
		$( "#datepicker").datepicker({
			dateFormat: "yy-mm-dd",
			yearRange: '1945:+0',
			changeMonth: true,
			changeYear: true,
		});
		
		$( "#datepickers").datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: "yy-mm-dd",
			yearRange: '1945:+0',
			constrainInput: false
		});
		$("#txtphone").keydown(function(e){
			var c = e.keyCode ;
			if( 
				( c>=48 && c<=57 ) || // number on top 
				( c>=96 && c<=105 ) || // number on numlock
				( c<=36 ) || // home key
				( c<=35 ) || // end key
				( c<=46 ) || // delete key
				( c<=8 ) || // backspace key
				( c<=20 ) || // backspace key
				( c<=9 ) || // tap key
				( c<=16 ) || // shift key
				( c<=17 ) || // ctrl key
				( c<=18 ) || // alt key
				( c<=37 ) || // arrow left
				( c<=38 ) || // arrow top
				( c<=39 ) || // arrow right
				( c<=40 ) // arrow down
			){
				
			}else {
				return false;
			}
		});
		
		/*$("#datepicker").keydown(function(e){
			var c = e.keyCode ; 
			if( 
				( c>=65 && c<=90 ) ||
				( c<=36 ) || // home key
				( c<=35 ) || // end key
				( c<=46 ) || // delete key
				( c<=8 ) || // backspace key
				( c<=20 ) || // backspace key
				( c<=9 ) || // tap key
				( c<=16 ) || // shift key
				( c<=17 ) || // ctrl key
				( c<=18 ) || // alt key
				( c<=37 ) || // arrow left
				( c<=38 ) || // arrow top
				( c<=39 ) || // arrow right
				( c<=40 ) // arrow down
			){
				
			}else {
				return false;
			}
		});*/
		$("#txtnation").keydown(function(e){
			var c = e.keyCode ;
			//alert(c);return;
			if( 
				
				( c>=65 && c<=90 ) || 
				( c<=36 ) || // home key
				( c<=35 ) || // end key
				( c<=46 ) || // delete key
				( c<=8 ) || // backspace key
				( c<=20 ) || // backspace key
				( c<=9 ) || // tap key
				( c<=16 ) || // shift key
				( c<=17 ) || // ctrl key
				( c<=18 ) || // alt key
				( c<=37 ) || // arrow left
				( c<=38 ) || // arrow top
				( c<=39 ) || // arrow right
				( c<=40 ) // arrow down
			){
				
			}else {
				return false;
			}
		});
		$("#txtother").keydown(function(e){
			var c = e.keyCode ;
			if( 
				( c>=48 && c<=57 ) || // number on top 
				( c>=96 && c<=105 ) || // number on numlock
				( c<=36 ) || // home key
				( c<=35 ) || // end key
				( c<=46 ) || // delete key
				( c<=8 ) || // backspace key
				( c<=20 ) || // backspace key
				( c<=9 ) || // tap key
				( c<=16 ) || // shift key
				( c<=17 ) || // ctrl key
				( c<=18 ) || // alt key
				( c<=37 ) || // arrow left
				( c<=38 ) || // arrow top
				( c<=39 ) || // arrow right
				( c<=40 ) // arrow down
			){
				
			}else {
				return false;
			}
		});
		$("#txtzip").keydown(function(e){
			var c = e.keyCode ;
			if( 
				( c>=48 && c<=57 ) || // number on top 
				( c>=96 && c<=105 ) || // number on numlock
				( c<=36 ) || // home key
				( c<=35 ) || // end key
				( c<=46 ) || // delete key
				( c<=8 ) || // backspace key
				( c<=20 ) || // backspace key
				( c<=9 ) || // tap key
				( c<=16 ) || // shift key
				( c<=17 ) || // ctrl key
				( c<=18 ) || // alt key
				( c<=37 ) || // arrow left
				( c<=38 ) || // arrow top
				( c<=39 ) || // arrow right
				( c<=40 ) // arrow down
			){
				
			}else {
				return false;
			}
		});
		$("#txtsalary").keydown(function(e){
			var c = e.keyCode ;
			if( 
				( c>=48 && c<=57 ) || // number on top 
				( c>=96 && c<=105 ) || // number on numlock
				( c<=36 ) || // home key
				( c<=35 ) || // end key
				( c<=46 ) || // delete key
				( c<=8 ) || // backspace key
				( c<=20 ) || // backspace key
				( c<=9 ) || // tap key
				( c<=16 ) || // shift key
				( c<=17 ) || // ctrl key
				( c<=18 ) || // alt key
				( c<=37 ) || // arrow left
				( c<=38 ) || // arrow top
				( c<=39 ) || // arrow right
				( c<=40 ) // arrow down
			){
				
			}else {
				return false;
			}
		});
		$("#txtcompany").keydown(function(e){
			var c = e.keyCode ;
			if(		( c==188 ) || // , key
					( c==59 ) // ; key
			){
				return false;
			}
		});
		$("#edu_txtschool").keydown(function(e){
			var c = e.keyCode ;
			if(		( c==188 ) || // , key
					( c==59 ) // ; key
			){
				return false;
			}
		});
		$("#edu_txtmajor").keydown(function(e){
			var c = e.keyCode ;
			if(		( c==188 ) || // , key
					( c==59 ) // ; key
			){
				return false;
			}
		});
		$("#edu_txtdegree").keydown(function(e){
			var c = e.keyCode ;
			if(		( c==188 ) || // , key
					( c==59 ) // ; key
			){
				return false;
			}
		});
		$(".txtduration").keydown(function(e){
			var c = e.keyCode ;
			if( 
				( c>=48 && c<=57 ) || // number on top 
				( c>=96 && c<=105 )|| // number on numlock
				( c==8 )
			){
				
			}else {
				return false;
			}
		});
		$("#edu_txtduration_from").keydown(function(e){
			var c = e.keyCode ;
			if( 
				( c>=48 && c<=57 ) || // number on top 
				( c>=96 && c<=105 ) ||  // number on numlock
				(c == 8)
			){
				
			}else {
				return false;
			}
		});
		$("#edu_txtduration_to").keydown(function(e){
			var c = e.keyCode ;
			if( 
				( c>=48 && c<=57 ) || // number on top 
				( c>=96 && c<=105 ) ||  // number on numlock
				(c == 8)
			){
				
			}else {
				return false;
			}
		});
		$("#txtemail").keydown(function(){
			//[a-zA-Z_.0-9]{1,255}@.*[.].*
			var match = $(this).val().match(/[a-zA-Z_.0-9]{1,255}@.*[.]*/g);
			if(match!=null);
		});
		
		$("#txtReference").keydown(function(){
			//[a-zA-Z_.0-9]{1,255}@.*[.].*
			var match = $(this).val().match(/[a-zA-Z_.0-9]{1,255}@.*[.]*/g);
			if(match!=null);
		});
		$(".in_pup_closer").click(function(){
			$(".in_pup_holder").slideUp();
			$(".in_pup").slideUp(function(){
				$(".in_pup_holder").slideDown();
			});
		});
		$(".view").click(function(){
			$.ajax({
				url:"<?php echo $this->getPath(array('resume'=>'view'));?>",
				type:"POST",
				data:{},
				beforeSend:function(){},
				success:function(data){
					$(".in_pup_holder").html(data);
	  				$(".in_pup").slideDown();
				}
			});
	  	});
		
		$(".boxclose").click(function(){
            $(".in_pup").slideUp();
        });
        $("a").click(function(){
            $(".in_pup").slideUp();
        });
        
        $(".upload_file").click(function(){
			$.ajax({
				url:"<?php echo $this->getPath(array('resume'=>'upattach'));?>",
				type:"post",
				data:{},
				success:function(response){
					$(".in_pup_holder").html(response);
					$(".in_pup").slideDown();
				}
			});
		});
        
       //save all field of work experience to server
    	$(".save").click(function(){
    			// collect all values from input type=textbox that name = txtduration
           		var work_ex_duration_from = [] ;
           		var work_ex_duration_to = [] ;
           		var work_ex_company = [] ;
           		var work_ex_position = [] ;
           		var edu_txtduration_from = [];
           		var edu_txtduration_to = [];
           		var edu_txtschool = [];
           		var edu_txtdegree = [];
           		var edu_txtmajor = [];
           		var work_ex_salary = [] ;
           		var more_degree = [];
           		
           		$("select[name='cbEdu']").each(function(){
            		if($(this).val()){
            			more_degree.push($(this).val());
            		}
            	});
           		
           		var other_degree = "";
            	for(var i=0;i < more_degree.length;i++){
            		other_degree+= more_degree[i] + ":" ;
    			}
            	$("#othercbEdu").val(other_degree.substring(0,other_degree.length -1 ));
            	
        		$("input[name='txtduration_from']").each(function(){
        			if($(this).val()){ // if no value not allow add to array
        				work_ex_duration_from.push($(this).val()); //add element to array
        				//$("#work_ex_duration").val(work_ex_duration); // set the value to hidden field work_ex_duration in editcv.at
        			}
        		});
        		$("input[name='txtduration_to']").each(function(){
        			if($(this).val()){ // if no value not allow add to array
        				work_ex_duration_to.push($(this).val()); //add element to array
        				//$("#work_ex_duration").val(work_ex_duration); // set the value to hidden field work_ex_duration in editcv.at
        			}
        		});
        		// collect all values from input type=textbox that name = txtposition
    			$("select[name='cboposition']").each(function(){
    				if($(this).val()){ // if no value not allow add to array	
    					work_ex_position.push($(this).val()); //add element to array
    					//$("#work_ex_position").val(work_ex_position); // set the value to hidden field work_ex_position in editcv.at
    				}
    			}); 
    			
    			// collect all values from input type=textbox that name = txtcompany
    			$("input[name='txtcompany']").each(function(){
    				if($(this).val()){ // if no value not allow add to array
    					work_ex_company.push($(this).val()); //add element to array
    					//$("#work_ex_company").val(work_ex_company); // set the value to hidden field work_ex_company in editcv.at
    				}
    			});
    			$("input[name='txtsalary']").each(function(){
    				if($(this).val()){
    					work_ex_salary.push($(this).val());
    				}
    			});
    			
    			var str = "" ;
    			var str_all_position = "";
    			for (var i = 0 ; i < work_ex_duration_from.length; i++){
    					str+=work_ex_duration_from[i]+":"+ work_ex_duration_to[i] + ":" + work_ex_position[i] + ":" + work_ex_company[i] + ":" + work_ex_salary[i]+  "|" ;
        				str_all_position+=  work_ex_position[i] + ":";
    			}
    			$("#work_experience").val(str.substring(0,str.length-1));
    			$("#all_position").val(str_all_position.substring(0,str_all_position.length-1));
    			// collect all values from input type=textbox that name = edu_txtduration
    			$("input[name='edu_txtduration_from']").each(function(){
    				if($(this).val()){ // if no value not allow add to array
    					edu_txtduration_from.push($(this).val()); //add element to array
    					//$("#txtmore_edu_duration").val(edu_txtduration); // set the value to hidden field work_ex_company in editcv.at
    				}
    			});
    			$("input[name='edu_txtduration_to']").each(function(){
    				if($(this).val()){ // if no value not allow add to array
    					edu_txtduration_to.push($(this).val()); //add element to array
    					//$("#txtmore_edu_duration").val(edu_txtduration); // set the value to hidden field work_ex_company in editcv.at
    				}
    			});
    			$("input[name='edu_txtschool']").each(function(){
    				if($(this).val()){ // if no value not allow add to array
    					edu_txtschool.push($(this).val()); //add element to array
    					//$("#txtmore_edu_school").val(edu_txtschool); // set the value to hidden field work_ex_company in editcv.at
    				}
    			});
    			$("select[name='cbodegree']").each(function(){
    				if($(this).val()){ // if no value not allow add to array
    					edu_txtdegree.push($(this).val()); //add element to array
    					//$("#txtmore_edu_degree").val(edu_txtdegree); // set the value to hidden field work_ex_company in editcv.at
    				}
    			});
    			$("select[name='cbomajor']").each(function(){
    				if($(this).val()){ // if no value not allow add to array
    					edu_txtmajor.push($(this).val()); //add element to array
    					//$("#txtmore_edu_major").val(edu_txtmajor); // set the value to hidden field work_ex_company in editcv.at
    				}
    			});
    			
    			var str_edu = "";
    			var str_all_degree = "";
    			var str_all_major = "";
    			for(var i=0;i<edu_txtduration_from.length;i++){
    				str_edu+= edu_txtduration_from[i]+":"+ edu_txtduration_to[i] +":" +edu_txtschool[i]+":"+edu_txtdegree[i]+":"+edu_txtmajor[i]+"|";
    				str_all_degree+= edu_txtdegree[i]+":";
    				str_all_major+= edu_txtmajor[i]+":";
    			}
    			$("#txtmore_education").val(str_edu.substring(0,str_edu.length-1));
    			$("#txt_all_degree").val(str_all_degree.substring(0,str_all_degree.length-1));
    			$("#txt_all_major").val(str_all_major.substring(0,str_all_major.length-1));
    			
    			//set all language string to hidden controll in editcv named languages
    			var lang = [] ;
    			var rdo_lang = [] ;
    			var lang_str = "" ;
    			$(".txt_lang").each(function(){
    				if($(this).val()){
    					lang.push($(this).val()); // start to add more array element to array language
    				}
    			});
    			$(".chk input:radio:checked").each(function(){
    				rdo_lang.push($(this).val());
    			});
    			for(var i=0;i<lang.length;i++){
    				lang_str+=lang[i] + ":"+ rdo_lang[i]+",";
    			}
    			$("#languages").val(lang_str.substring(0,lang_str.length-1));
    			
    			//end set lang string to hidden control named languages
           	});
		// more other phone
		$(".more_other").click(function(){
			var moi = document.createElement("div");
			$(moi).attr("class","more_other_i");
			var input = document.createElement("input");
			$(input).attr("type","text").attr("class","txtother").attr("name","txtother");
			var remove = document.createElement("input");
			$(remove).attr("type","button").attr("class","remover").attr("value","Remove").attr("title","click to remove this phone");
			$(remove).click(function(){
				$(this).parent().remove();
			});
			$(moi).append(input).append(remove);
			$(this).parent().parent().append(moi);
			// collect all values from input type=textbox that named = txtother
			$(input+"[name='txtother']").each(function(){
				if($(this).val()){ // if no value not allow add to array
					var phones = [] ;
					phones.push($(this).val()); //add element to array
					$("#phones").val(phones); // set the value to hidden field phones in editcv.at
				}
			}); 
		});
		var click_count =  1 ; // this variable to trick how many language button add has been hit and the set to different name of radio button
		//create more language
		$("#more_l").click(function(){
			var lang = [];
			$(".chk input:radio").each(function(){
				var name = $(this).attr("name");
				lang.push(name.slice(-1));
			});
			if(lang instanceof Array){
				var  max = Math.max.apply(Math, lang);
				click_count = max + 1;
			}else{
				click_count++;
			}
			var drow = document.createElement("div");
			$(drow).attr("class","drow");
			var lan = document.createElement("div");
			$(lan).attr("class","dcell dcell_30per dcell_txright");
			var input_l = document.createElement("input");
			$(input_l).attr("name","txt_lang").attr("class","txt_lang").attr("title","enter your language").attr("placeholder","language");
			$(lan).append(input_l);
			$(this).parent().append(lan);
			
			var order = document.createElement("div");
			$(order).attr("class","dcell dcell_65per");
			var main_ch = document.createElement("div");
			$(main_ch).attr("class","main_h_v");
			var chk = document.createElement("div");
			$(chk).attr("class","chk_1 chk");
			var chk1 = document.createElement("div");
			$(chk1).attr("class","chk_1 chk");
			var chk2 = document.createElement("div");
			$(chk2).attr("class","chk_1 chk");
			var chk3 = document.createElement("div");
			$(chk3).attr("class","chk_1 chk");
			var chk4 = document.createElement("div");
			$(chk4).attr("class","chk_1 chk");
			var input_v = document.createElement("input");
			$(input_v).attr("type","radio").attr("name","language"+click_count).attr("value","1");
			var input_g = document.createElement("input");
			$(input_g).attr("type","radio").attr("name","language"+click_count).attr("value","2");
			var input_f = document.createElement("input");
			$(input_f).attr("type","radio").attr("name","language"+click_count).attr("value","3");
			var input_p = document.createElement("input");
			$(input_p).attr("type","radio").attr("name","language"+click_count).attr("value","4");
			var input_e = document.createElement("input");
			$(input_e).attr("type","radio").attr("name","language"+click_count).attr("value","5");
			var remove_l = document.createElement("input");
			$(remove_l).attr("type","button").attr("class","remove_l").attr("id","remove_l").attr("value","Remove").attr("title","click to remove this");
			$(chk).append(input_v);
			$(chk1).append(input_g);
			$(chk2).append(input_f);
			$(chk3).append(input_p);
			$(chk4).append(input_e);
			$(main_ch).append(chk).append(chk1).append(chk2).append(chk3).append(chk4).append(remove_l);
			$(order).append(main_ch);
			$(drow).append(lan).append(order);
			$(".drows").append(drow);
			//$(this).parent().append(drow);
			// remove 
			$(remove_l).click(function(){
				$(this).parent().parent().parent().remove();
			});
			
		});
	  
		// New location 
		$("select").change(function(){
			var me = this ;
			if($(me).val()=="createnew"){
				var input = document.createElement("input");
				$(input).attr("class","txtnewoption " + "new"+$(me).attr("name") ).attr("type","text").attr("placeholder","please input...")||$(input).attr("type","button").attr("class","abc").attr("value","Add");
				$(me).parent().append(input);
				//$(input).hide();
				$(input).slideDown(function(){
					$(input).focus();
					$(input).attr("name",$(me).attr("name")) ; // add attribute name to new control was appended 
					$(me).removeAttr("name"); // remove attribute name from original 
				});
				$(this).attr("name",$(".txtnewoption").val());
			}else{
				$(this).parent().find(".txtnewoption").slideUp(function(){
					$(this).remove();
				});
			}
		});
		
		//for new position that doesn't have in list 
		$(".dcell1_65per").delegate("select","change",function(event){
			if($(this).val()=="createnew_position"){
			    var position = prompt("Please enter the new one","");
			    if (position != "") {
			    	//selbox.options[selbox.options.length] = new Option(position,position).setAttribute(position,position);
			    	//var l = $("#cboposition").append(new option(position,position));
			    	var op = document.createElement("option");
			    	$(op).attr("value",position).attr("selected","selected");
			    	$(op).append(position);
			    	$(this).append(op);
			    	// document.getElementById("txtposition").value = position;
			       // document.getElementById("txtposition").value = position;
			    }else {
				    	var id = $(this).attr("id");
			    	
			    }
			   if(position == "" || position == null){
				    	$(this).children(":first").remove();
				    	var op = document.createElement("option");
				    	$(op).attr("value","").attr("selected","selected");
				    	var id = $(this).attr("id");
				    	switch (id){
				    		case "cboposition" : $(op).append("Select Position");break;
				    		case "edu_txtdegree" : $(op).append("Select Degree");break;
				    		case "edu_major" : $(op).append("Select Major");break;
				    	}
				    	$(this).prepend(op);
			    	}
			}
		});
	
		//pass all phone to server side when clicking on submit
		$(".save").click(function(){
			var phone = [];
			$("input[name='txtother']").each(function(){
				if($(this).val()){
					phone.push($(this).val());
					$("#phones").val(phone);
				}
			});
		});
		$(".save").click(function(){
			var postcode = [];
			$("input[name='txtzip']").each(function(){
				if($(this).val()){
					postcode.push($(this).val());
					$("#postcode").val(postcode);
				}
			});
		});
		$(".save").click(function(){
			var country = [];
			$("input[name='txtcountry']").each(function(){
				if($(this).val()){
					country.push($(this).val());
					$("#postcode").val(country);
				}
			});
		});
		
		$(".validCategory").hide();
		$(".validName").hide();
		$(".validG").hide();
		$(".validDOB").hide();
		$(".validNationality").hide();
		$(".validEmail").hide();
		$(".validPhone").hide();
		$(".validadd").hide();
		$(".validOphone").hide();
		$(".validInvalidEmail").hide();
		$(".validInvalidReference").hide();
		
		/**
          *
          * modifie by : Mr.chamnan
          * date: 2014-03-22 
        */
        //autocomplete for category
        $("#auto_box_cat").hide();
        $("#cbocategory").hide();
       
        $("#cbo_auto_category").click(function(){
        	$("cbocategory").css("display","block");
	    	$("#cbocategory").slideToggle();
	    	
	    });
	    $("#auto_box_cat").click(function(){
	    	$("#cbocategory").slideUp();
	    });
	    /******End******/
	});
	function validateEmail(){
	    var email=$("#txtemail").val();
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            if(email && !filter.test(email)){
                  $(".validInvalidEmail").show().css("color","red");
            }else{
                $(".validInvalidEmail").hide();
            }
	}
	function validateReference(){
	    var email=$("#txtReference").val();
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            if(email && !filter.test(email)){
                  $(".validInvalidReference").show().css("color","red");
            }else{
                $(".validInvalidReference").hide();
            }
	}
	function validationForm(){ 
		
	    var category=$("#combobox_cat").val();
	    var name=$("#txname").val();
	    var gender=$("#cbgender").val();
	    var dobs=$("#datepicker").val();
	    var national=$("#txtnation").val();
	    var email=$("#txtemail").val();
	    var phone=$("#txtphone").val();
	    var add=$("#txadd").val();
	    //var otherphone=$("#txtother").val();
	    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	       if(name=="" && gender=="" && dobs=="" && national=="" && add=="" && phone==""   ){
                $(".validName").show().css("color","red").delay(5000).fadeOut();
                $(".validG").show().css("color","red").delay(5000).fadeOut();
                $(".validDOB").show().css("color","red").delay(5000).fadeOut();
                $(".validNationality").show().css("color","red").delay(5000).fadeOut();
                $(".validadd").show().css("color","red").delay(5000).fadeOut();
                $(".validEmail").show().css("color","red").delay(5000).fadeOut();
                $(".validPhone").show().css("color","red").delay(5000).fadeOut(); 
                $(".validInvalidEmail").hide(); 
                return false;
	       }else if(name==""){ 
	    	   $(".validName").show().css("color","red").delay(5000).fadeOut(); 
	    	   $(".focus_name").focus();
                $(".validG").hide();
                $(".validDOB").hide();
                $(".validNationality").hide();
                $(".validEmail").hide();
                $(".validPhone").hide();
                $(".validadd").hide(); 
                //$(".validOphone").hide();
                $(".validInvalidEmail").hide();
                return false;
           }else if(gender==""){ 
                $(".validName").hide();
                $(".validG").show().css("color","red").delay(5000).fadeOut();
                $(".cbgender").focus();
	            $(".validDOB").hide();
                $(".validNationality").hide();
                $(".validEmail").hide();
                $(".validPhone").hide();
                $(".validadd").hide();
               // $(".validOphone").hide();
                $(".validInvalidEmail").hide();
                return false;
	       }else if(dobs==""){ 
                $(".validName").hide();
                $(".validG").hide();
	            $(".validDOB").show().css("color","red").delay(5000).fadeOut();
	            $("#datepicker").focus();
                $(".validNationality").hide();
                $(".validEmail").hide();
                $(".validPhone").hide();
                $(".validadd").hide();
               // $(".validOphone").hide();
                $(".validInvalidEmail").hide();
                return false;
	       }else if(national==""){ 
                $(".validName").hide();
                $(".validDOB").hide();
                $(".validNationality").show().css("color","red").delay(5000).fadeOut();
                $(".focus_n").focus();
                $(".validEmail").hide();
                $(".validPhone").hide();
                $(".validadd").hide();
                $(".validOphone").hide();
                $(".validInvalidEmail").hide();
                return false;
           }else if(add==""){ 
               $(".validName").hide();
               $(".validDOB").hide();
               $(".validNationality").hide();
               $(".validEmail").hide();
               $(".validPhone").hide();
               $(".validadd").show().css("color","red").delay(5000).fadeOut();
               $(".focus_add").focus();
               $(".validOphone").hide();
               $(".validInvalidEmail").hide();
               return false;
           /*}else if(email==""){ 
                $(".validName").hide();
                $(".validDOB").hide();
                $(".validNationality").hide();
                $(".validEmail").show().css("color","red").delay(5000).fadeOut();
                $(".focus_email").focus();
                $(".validPhone").hide();
                $(".validadd").hide();
               //$(".validOphone").hide();
                $(".validInvalidEmail").hide();
                return false;*/
           }else if(email && !filter.test(email)){
                $(".validCategory").hide();
                $(".validName").hide();
                $(".validNationality").hide();
                $(".validEmail").hide();
                $(".validPhone").hide();
                $(".validadd").hide();
               // $(".validOphone").hide();
                $(".validInvalidEmail").show();
                return false;
           }else if(phone==""){ 
                $(".validName").hide();
                $(".validDOB").hide();
                $(".validNationality").hide();
                $(".validEmail").hide();
                $(".validPhone").show().css("color","red").delay(5000).fadeOut();
                $(".focus_phone").focus();
                $(".validadd").hide();
              //  $(".validOphone").hide();
                $(".validInvalidEmail").hide();
                return false;
           }
           /*else if(otherphone==""){
                $(".validCategory").show();
                $(".validName").hide();
                $(".validNationality").hide();
                $(".validEmail").hide();
                $(".validPhone").hide();
             //   $(".validOphone").show();
                $(".validInvalidEmail").hide();
                return false;
           }*/
	}
	function getCat(cat_name,cat_id){
		document.getElementById("txtcategory").value = cat_name;
		document.getElementById("cbocategory").value = cat_id;
	}
	function cat_empt(){
		document.getElementById("txtcategory").value = "";
		document.getElementById("cbocategory").value = "";
	}
	function search_cat( request, response ) {
		var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
		response( this.element.children( "option" ).map(function() {
			var text = $( this ).text();
			if ( this.value && ( !request.term || matcher.test(text) ) )
			return {
			label: text,
			value: text,
			option: this
			};
		}) );
	}